package cn.anquing.shardingsphere.demo;

import cn.anquing.shardingsphere.demo.entity.Demo;
import cn.anquing.shardingsphere.demo.entity.Order;
import cn.anquing.shardingsphere.demo.service.OrderService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wangqq65
 * @since 2021/9/7 9:24
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @GetMapping("/{orderId}")
    public Order list(@PathVariable("orderId") Long orderId){
        return orderService.getByOrderId(orderId);
    }

    @GetMapping("/list")
    public List<Order> list(){
        return orderService.listAll();
    }
}
